//
//  XMHomePagePorductCell.m
//  XMJJ_zml
//
//  Created by 丁浩 on 2025/7/2.
//

#import "XMHomePagePorductCell.h"

@interface XMHomePagePorductCell ()

@property (nonatomic, strong) UIImageView *coverImgView;
@property (nonatomic, strong) UIButton *likeBtn;

@end

@implementation XMHomePagePorductCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
    }
    return self;
}

- (void)creatUI {
    self.backgroundColor = kColorHEX(0xF5F5F5);
    UIView *contentView = [[UIView alloc] initWithFrame:self.bounds];
    contentView.backgroundColor = kColorHEX(0xffffff);
    [contentView setCornerRadius:KScaleWidth(8.0)];
    [self addSubview:contentView];
    
    [contentView addSubview:self.coverImgView];
    [contentView addSubview:self.likeBtn];
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScaleWidth(8.0), _coverImgView.maxY + KScaleWidth(3.0), self.width/2 - KScaleWidth(8.0), KScaleWidth(18.0)) font:KFontSize(13.0) textColor:kColorHEX(0x333333)];
    titleLabel.text = @"图文";
    [contentView addSubview:titleLabel];
}

- (void)setContentWithProductModel:(XMPicwordModel *)productModel {
    [_coverImgView sd_setImageWithURL:[NSURL URLWithString:productModel.coverImageUrl]];
}

- (void)likeAction:(UIButton *)button {
    
}

#pragma mark - Init
- (UIImageView *)coverImgView {
    if (!_coverImgView) {
        _coverImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, KScaleWidth(128.0))];
    }
    return _coverImgView;
}

- (UIButton *)likeBtn {
    if (!_likeBtn) {
        _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom frame:CGRectMake(self.width - KScaleWidth(32.0), self.coverImgView.maxY + KScaleWidth(3.0), KScaleWidth(32.0), KScaleWidth(18.0)) image:@"evaluate_like_icon" selectImg:@"evaluate_like_icon_select"];
        [_likeBtn addTarget:self action:@selector(likeAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _likeBtn;
}

@end
